from flask import Flask, render_template
from flask_wtf import FlaskForm
from wtforms import StringField

app = Flask(__name__)
app.secret_key = 'abcdef'


class MyForm(FlaskForm):
    username = StringField('账号')
    password = StringField('密码')


@app.route('/login', methods=['GET', 'POST'])
def login():
    form = MyForm()
    if form.validate_on_submit():
        return f'你好：{form.username.data} 密码:{form.password.data}'
    return render_template('login.html', form=form)


if __name__ == '__main__':
    app.run()
